package juego.roles;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import juego.graficos.*;

public class Mario extends JLabel implements Runnable {

	protected AnimatedSprite actual;
	protected AnimatedSprite quieto;
	protected AnimatedSprite derecha;
	//protected AnimatedSprite izquierda;
	protected AnimatedSprite salto;
	
	private int vidas;
	private int level;
	
	public Mario()
	{
		super();
		
		this.quieto = new AnimatedSprite();
		this.quieto.addImage(new ImageIcon( getClass().getClassLoader().getResource("juego/imagenes/quieto.gif")) );		
		
		this.derecha = new AnimatedSprite();		
		this.derecha.addImage(new ImageIcon( getClass().getClassLoader().getResource("juego/imagenes/camina1.gif")) );
		this.derecha.addImage(new ImageIcon( getClass().getClassLoader().getResource("juego/imagenes/camina2.gif")) );
		this.derecha.addImage(new ImageIcon( getClass().getClassLoader().getResource("juego/imagenes/camina3.gif")) );
		
		this.salto = new AnimatedSprite();
		this.salto.addImage(new ImageIcon( getClass().getClassLoader().getResource("juego/imagenes/salto.gif")) );
		
		this.actual = this.quieto;
		this.setIcon(this.quieto.getImage());
		
		this.vidas = 1;
		this.level = 0;
	}
	
	public void run() {
		while( true ) 
		{
			try
			{
				this.setIcon(this.actual.getImage());
				Thread.sleep(100);
			}
			catch( Exception e )
			{
				e.getMessage();
			}
		}		
	}
	
	public void goQuieto()
	{
		this.actual = this.quieto;
	}
	
	public void goDerecha()
	{
		this.actual = this.derecha;
	}
	
	//public void goIzquierda()
	//{
	//	this.actual = this.izquierda;
	//}
	
	public void goSalto()
	{
		this.actual = this.salto;
	}
	
	public AnimatedSprite getImage()
	{
		return actual;
	}
	
	protected Object clonar()
	{
		Mario m = new Mario();
		return m;
	}
}
